<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>校产类别-云校通_教师版</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="<%=basePath%>/css/xcgl_kcgl.css"/>
    <link rel="stylesheet" href="<%=basePath%>/style/icon.css"/>
    <style>
      .main{
        background: #fff;
      }
      .weui_panel_bd{
        border-bottom: 1px solid #ccc;
      }
      .weui_panel_bd .icon{
        position: absolute; right: 4%;
      }
      .weui_panel_bd .big_size{
        float: left;
        margin-bottom: 8px;
        margin-right: 12%;
        font-size: 15px;
      }
      .btnBox{
      	z-index: 4;
        position: fixed; right: 7%; bottom: 10%;
        width: 70px; height: 70px;
      }
      .btnBox img{
        width: 70px; height: 70px;
      }
    </style>
  </head>
  <body ontouchstart>
   <jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
    <div class="weui-header bg-blue"> 
		<div class="weui-header-left"> <a onclick="back()" class="icon icon-109 f-white">返回</a></div>
		<h1 class="weui-header-title">物品类别</h1>
    </div>
    
    <div class="main" style=" margin-bottom:60px">
       <div class="TypeList"></div>
    <div class="btnBox"> <a href="goodTypeManageIndex/add"> <img src="<%=basePath%>/images/addBtnnew.png"> </a></div>
    </div>
     <script src="<%=basePath%>/js/zepto.min.js"></script>
     <script src="<%=basePath%>/js/swipe.js"></script>
    <jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
     <script>
     var page = 0,size = 5; 
$(function(){
    $('.main').dropload({
        scrollArea : window,
        autoLoad : true,
  		domDown : {
            domClass   : 'dropload-down',
            domRefresh : '<div class="dropload-refresh f10 " ><i class="icon icon-20"></i>上拉加载更多</div>',
            domLoad    : '<div class="dropload-load f10"><span class="weui-loading"></span>正在加载中...</div>',
            domNoData  : '<div class="dropload-noData">没有更多数据了</div>'
        },
        domUp : {
            domClass   : 'dropload-up',
            domRefresh : '<div class="dropload-refresh"><i class="icon icon-114"></i>上拉加载更多</div>',
            domUpdate  : '<div class="dropload-load f10"><i class="icon icon-20"></i>释放更新...</div>',
            domLoad    : '<div class="dropload-load f10"><span class="weui-loading"></span>正在加载中...</div>'
        },
        loadDownFn : function(me){
	        page++;
			window.params = {
				page: page,
	  	 		rows: size
			};	            
	       	$.ajax({
	          	url : basePath + "/ls/school/property/type/query",
	  	 		type : "post",
	  	 		dataType : "json",
	  	 		data : window.params,
	            success: function(data){
	         		 if(data.data.rows.length == 0 || window.params.page*window.params.rows >= data.data.total) {
	                      me.lock();
	                      me.noData();
	                  }
	                  // 为了测试，延迟1秒加载
	                  setTimeout(function(){
	                	 loadDataToHtml(data.data);
	                    me.resetload();
	                  },1000);
	              },
	              error: function(xhr, type){
	              }
	          });
        }
    });
});
function loadDataToHtml(data) {
	if(data.rows.length > 0) {
		var html = "";
		for(var i in data.rows) {
			var item = data.rows[i];
			html += '<div class=\"weui_panel_bd clear\">\
		             <div class="weui_media_box weui_media_text">\
	                        <h4 class="weui_media_title">类别名称:'+ item.typeName +'</h4>\
	                          <p class="weui_media_desc big_size f-black">是否消耗品: '+ change(item.cycleUse) + ' </p>\
	                          <p class="weui_media_desc clear">' + new Date(item.createTieme).toLocaleString() + '</p>\
	                      </div>\
	                  </div>';
		}
		$('.TypeList').append(html);
	}
}

function change(str){
	if(str == 0)
		return "是"
	if(str == 1)
		return "否"
	return "";	
}
function formate(str){
	return new Date(str).toLocaleString();
}
</script>
  </body>
</html>